// pages/SocialSecurityCard/SocialSecurity_all/SocialSecurity_all.js
import {
  queryTempFunctionCode
} from '../../../utils/login'
import {saveMatter} from '../../../utils/my'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    menuInfo: {},
    str: [{
        id: '1',
        name: '社会保障卡信息查询',
        src: '/images/more/sb1.png',
        url: '/pages/SocialSecurityCard/Card_query/Card_query',
        code: 'SHBZK_0007',
        icon: 'sbk1'
      },
      {
        id: '2',
        name: '社会保障卡个人首次申请',
        src: '/images/more/sb2.png',
        url: '/pages/SocialSecurityCard/Card_FirstApplication/Card_FirstApplication',
        code: 'SHBZK_0002',
        icon: 'sbk2'
      },
      {
        id: '3',
        name: '社会保障卡启用',
        src: '/images/more/sb3.png',
        url: '/pages/SocialSecurityCard/Card_Enable/Card_Enable',
        code: 'SHBZK_0001',
        icon: 'sbk3'
      },
      {
        id: '4',
        name: '社会保障卡正式挂失',
        src: '/images/more/sb4.png',
        url: '/pages/SocialSecurityCard/Card_ReportingLoss/Card_ReportingLoss',
        code: 'SHBZK_0004',
        icon: 'sbk4'
      },
      {
        id: '5',
        name: '社会保障卡正式挂失解挂',
        src: '/images/more/sb5.png',
        url: '/pages/SocialSecurityCard/Card_Unhook/Card_Unhook',
        code: 'SHBZK_0003',
        icon: 'sbk5'
      },
      {
        id: '6',
        name: '社会保障卡补卡',
        src: '/images/more/sb6.png',
        url: '/pages/SocialSecurityCard/Card_repair/Card_repair',
        code: 'SHBZK_0005',
        icon: 'sbk6'
      },
      {
        id: '7',
        name: '社保卡制卡进度',
        src: '/images/more/sb7.png',
        url: '/pages/SocialSecurityCard/Card_schedule/Card_schedule',
        code: 'SHBZK_0006',
        icon: 'sbk7'
      },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    //设置头部字体与导航栏对齐
    const top = getApp()
    this.setData({
      menuInfo: top.geibartop.menuInfo
    })
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},
  //跳转页面
  jumpPage(e) {
    const code = e.currentTarget.dataset.code;
    const name = e.currentTarget.dataset.name;
    if (code) {
      queryTempFunctionCode(code).then(res => {
        saveMatter(name) //保存事项
        wx.navigateTo({
          url: '/pages/web_h5/web_h5?url=' + encodeURIComponent(res.data)
        })
      })
    } else {
      wx.showToast({
        title: '功能代码错误！',
        icon: 'error',
        duration: 2000
      })
    }
  },
  //返回上一级
  backPage() {
    wx.navigateBack({
      delta: 1
    });
  },
})